<template>
  <el-dialog v-model="visible" title="提示" :close-on-click-modal="false" :close-on-press-escape="false"
             style="width: 16%;top: 28%;height: 150px;">
    <!-- 修改提示内容 -->
    <div style="display: flex; align-items: center; margin-top: -20px;">
      <el-icon :size="20">
        <WarningFilled />
      </el-icon>
      <span style="margin-left: 10px;">是否审核通过?</span>
    </div>
    <div style="text-align: center;margin-top: 20px;">
      <!-- 修改按钮文案 -->
      <el-button type="primary" @click="pass()">审核通过</el-button>
      <el-button @click="nopass()">审核不通过</el-button>
    </div>
  </el-dialog>
</template>

<script lang="ts" setup>
import { reactive, ref } from "vue";
import baseService from "@/service/baseService";
import { useI18n } from "vue-i18n";
import { ElMessage } from "element-plus";
import { WarningFilled } from '@element-plus/icons-vue';

const { t } = useI18n();
const emit = defineEmits(["refreshDataList"]);

const visible = ref(false);
const dataFormRef = ref();

const dataForm = reactive({
  id: "",
  groupName: "",
  ids: [] as any[]
});

const init = (ids?: any[]) => {
  
  visible.value = true;
  dataForm.ids = ids || [];
  // 重置表单数据
  if (dataFormRef.value) {
    dataFormRef.value.resetFields();
  }
};

// 审核通过
const pass = () => {
  if (!dataForm.ids) return;
  baseService.post("/noc/nocmember/pass", dataForm.ids).then((res) => {
    Object.assign(dataForm, res.data);
    visible.value = false; // 关闭对话框
    emit('refreshDataList'); // 触发刷新数据列表
    ElMessage.success('审核通过');
  }).catch((error) => {
    console.error('审核失败:', error);
    ElMessage.error('审核失败');
  });
};

// 审核不通过
const nopass = () => {
  if (!dataForm.ids) return;
  baseService.post("/noc/nocmember/nopass", dataForm.ids).then((res) => {
    Object.assign(dataForm, res.data);
    visible.value = false; // 关闭对话框
    emit('refreshDataList'); // 触发刷新数据列表
    ElMessage.error('审核不通过');
  }).catch((error) => {
    console.error('操作失败:', error);
    ElMessage.error('操作失败');
  });
}

defineExpose({
  init
});
</script>

<style lang="scss" scoped>
::v-deep #el-id-4298-94 {
  padding: 0px
}

.el-dialog {
  top: 20%;
}
</style>
